package struts3.listener;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import struts3.form.XmlBean;
import struts3.util.Struts_Config;

public class ActionListener implements ServletContextListener {

	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("信息：系统已经成功注销!!!!!");

	}

	public void contextInitialized(ServletContextEvent arg0) {
		
		ServletContext context = arg0.getServletContext();
		String xmlPath = context.getInitParameter("struts-config");
		String tomcatPath = context.getRealPath("\\");
		try{
			Map<String,XmlBean> map = Struts_Config.parseXML(tomcatPath+xmlPath);
			context.setAttribute("struts", map);
		}catch (Exception e) {
			e.printStackTrace();
			System.out.println("错误：读取xml文件失败！！！！");
		}
		System.out.println("信息：系统已经全部加载完成！！！！");
	}

}
